package test;


public class DateFormat {
	// @JsonFormat 时间差一天问题加上时区
	private static String hexStr =  "0123456789ABCDEF";
	public static void main(String[] args) throws Exception {
		byte[]b=new byte[2];
		b[0]=(byte) 0xff;
		b[1]=0x08;
		System.out.println(BinaryToHexString(b));
	}
	public static int OxStringtoInt(String ox) throws Exception {
	    ox = ox.toLowerCase();
	    if (ox.startsWith("0x")) {
	        ox = ox.substring(2, ox.length());
	    }
	    Integer ri = 0;
	    Integer oxlen = ox.length();
	    for (int i = 0; i < oxlen; i++ ) {
	        char c = ox.charAt(i);
	        int h;
	        if (('0' <= c && c <= '9')) {
	            h = c - 48;
	        } else if (('a' <= c && c <= 'f')) {
	            h = c - 87;
	 
	        } else if ('A' <= c && c <= 'F') {
	            h = c - 55;
	        } else {
	            throw (new Exception("not a integer "));
	        }
	        byte left = (byte) ((oxlen - i - 1) * 4);
	        ri |= (h << left);
	    }
	    return ri;
	 
	}
	public static String BinaryToHexString(byte[] bytes){
		
        String result = "";  
        String hex = "";  
        for(int i=0;i<bytes.length;i++){  
            //字节高4位  
            hex = String.valueOf(hexStr.charAt((bytes[i]&0xF0)>>4));  
            //字节低4位  
            hex += String.valueOf(hexStr.charAt(bytes[i]&0x0F));  
            result +=hex+" ";  
        }  
        return result;  
}
}
